home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / utilsys / rss14gmd.lha / RSys_1.4gmd / C / Flush.c < prev    next >
C/C++ Source or Header  |  1996-05-04  |  4KB  |  239 lines

  1. /*
  2.    ***************************************************************************
  3.    *
  4.    * Datei:
  5.    *      RSysFlush.c
  6.    *
  7.    * Inhalt:
  8.    *
  9.    *      --- Globale Routinen ---
  10.    *
  11.    *    void RSysFlushAll ( void );
  12.    *    void RSysFlushAllFonts ( void );
  13.    *    void RSysFlushAllLibraries ( void );
  14.    *
  15.    *      --- Lokale  Routinen ---
  16.    *
  17.    *
  18.    * Bemerkungen:
  19.    *      Speicherfreigabe durch Beseitigen von nicht benutzten
  20.    *      Fonts und Libraries.
  21.    *
  22.    * Erstellungsdatum:
  23.    *      07-Jul-93     Rolf Böhme
  24.    *
  25.    * Änderungen:
  26.    *      07-Jul-93     Rolf Böhme        Erstellung
  27.    *
  28.    ***************************************************************************
  29.  */
  30.  
  31. #include "RSys.h"
  32. #include "protos.h"
  33.  
  34.  /*
  35.   * FlushAllLibraries() entfernt alle geschlossenen Libraries aus
  36.   * dem System
  37.   */
  38. void
  39. RSysFlushAllLibraries (void)
  40. {
  41.   LIBRARY *result;
  42.   NODE *node;
  43.   int old_lib_cnt = 0;        /* GMD */
  44.   int new_lib_cnt = 0;        /* GMD */
  45.   int diff_lib_cnt = 0;        /* GMD */
  46.   int flush_lib_cnt = 0;    /* GMD */
  47.   char buf[80];
  48.  
  49.   HandleHelp (MN_RSysFlushAllLibraries);
  50.  
  51.   Forbid ();
  52.   for (node = SysBase->LibList.lh_Head; node->ln_Succ;
  53.        node = node->ln_Succ)
  54.     {
  55.       ++old_lib_cnt;
  56.       result = (LIBRARY *) node;
  57.  
  58.       if (result->lib_OpenCnt == 0)
  59.     {
  60.       ++flush_lib_cnt;
  61.       RemLibrary (result);
  62.     }
  63.     }
  64.   Permit ();
  65.  
  66.   /*
  67.      * now see how many libraries flushed themselves
  68.    */
  69.   if (flush_lib_cnt)
  70.     {
  71.       Forbid ();
  72.       for (node = SysBase->LibList.lh_Head; node->ln_Succ;
  73.        node = node->ln_Succ)
  74.     {
  75.       ++new_lib_cnt;
  76.     }
  77.       Permit ();
  78.     }
  79.  
  80.   diff_lib_cnt = old_lib_cnt - new_lib_cnt;
  81.   if (flush_lib_cnt == 0)
  82.     {
  83.       sprintf (buf, "No flushable libraries");
  84.     }
  85.   else
  86.     {
  87.       sprintf (buf, "Flushable libraries = %d, actual flushed = %d",
  88.            flush_lib_cnt, diff_lib_cnt);
  89.     }
  90.  
  91.   PrintInfo (buf, SPEAK, (2 * SEC));
  92.  
  93.   RefreshList (LastID);
  94. /*
  95.    PrintStatistics ();
  96.  */
  97.  
  98.   return;
  99. }
  100.  
  101. /* 
  102.  * Flush Devices (GMD)
  103.  */
  104.  
  105. void
  106. RSysFlushAllDevices (void)
  107. {
  108.   LIBRARY *result;
  109.   NODE *node;
  110.   int old_devs_cnt = 0;        /* GMD */
  111.   int new_devs_cnt = 0;        /* GMD */
  112.   int diff_devs_cnt = 0;    /* GMD */
  113.   int flush_devs_cnt = 0;    /* GMD */
  114.   char buf[80];
  115.  
  116.   HandleHelp (MN_RSysFlushAllLibraries);
  117.  
  118.   Forbid ();
  119.   for (node = SysBase->DeviceList.lh_Head; node->ln_Succ;
  120.        node = node->ln_Succ)
  121.     {
  122.       ++old_devs_cnt;
  123.       result = (LIBRARY *) node;
  124.  
  125.       if (result->lib_OpenCnt == 0)
  126.     {
  127.       ++flush_devs_cnt;
  128.       RemDevice ((DEVICE *) result);
  129.     }
  130.     }
  131.   Permit ();
  132.  
  133.   /*
  134.      * now see how many devices flushed themselves
  135.    */
  136.   if (flush_devs_cnt)
  137.     {
  138.       Forbid ();
  139.       for (node = SysBase->DeviceList.lh_Head; node->ln_Succ;
  140.        node = node->ln_Succ)
  141.     {
  142.       ++new_devs_cnt;
  143.     }
  144.       Permit ();
  145.     }
  146.  
  147.   diff_devs_cnt = old_devs_cnt - new_devs_cnt;
  148.   if (flush_devs_cnt == 0)
  149.     {
  150.       sprintf (buf, "No flushable devices");
  151.     }
  152.   else
  153.     {
  154.       sprintf (buf, "Flushable devices = %d, actual flushed = %d",
  155.            flush_devs_cnt, diff_devs_cnt);
  156.     }
  157.  
  158.   PrintInfo (buf, SPEAK, (2 * SEC));
  159.  
  160.   RefreshList (LastID);
  161.  
  162.   PrintStatistics ();
  163.  
  164.   return;
  165. }
  166.  
  167.  
  168.  /*
  169.   * RSysFlushAllFonts() entfernt alle unbenutzten Diskfonts aus
  170.   * dem System
  171.   */
  172. void
  173. RSysFlushAllFonts (void)
  174. {
  175.   TEXTFONT *tf;
  176.   NODE *node;
  177.   int old_font_cnt = 0;        /* GMD */
  178.   int new_font_cnt = 0;        /* GMD */
  179.   int diff_font_cnt = 0;    /* GMD */
  180.   char buf[80];
  181.  
  182.   HandleHelp (MN_RSysFlushAllFonts);
  183.  
  184.   Forbid ();
  185.   for (node = GfxBase->TextFonts.lh_Head; node->ln_Succ;
  186.        node = node->ln_Succ)
  187.     {
  188.       tf = (TEXTFONT *) node;
  189.  
  190.       if ((tf->tf_Accessors == 0) && (tf->tf_Flags & FPF_DISKFONT))
  191.     {
  192.       ++old_font_cnt;
  193.       RemFont (tf);
  194.       Remove (node);
  195.     }
  196.     }
  197.   Permit ();
  198.  
  199.   /*
  200.      * now see how many fonts were  flushed
  201.    */
  202.  
  203.   Forbid ();
  204.   for (node = GfxBase->TextFonts.lh_Head; node->ln_Succ;
  205.        node = node->ln_Succ)
  206.     {
  207.       tf = (TEXTFONT *) node;
  208.  
  209.       if ((tf->tf_Accessors == 0) && (tf->tf_Flags & FPF_DISKFONT))
  210.     {
  211.       ++new_font_cnt;
  212.       RemFont (tf);
  213.       Remove (node);
  214.     }
  215.     }
  216.   Permit ();
  217.  
  218.   diff_font_cnt = old_font_cnt - new_font_cnt;
  219.   sprintf (buf, "%d fonts flushed", diff_font_cnt);
  220.  
  221.   PrintInfo (buf, SPEAK, (2 * SEC));
  222.  
  223.   RefreshList (LastID);
  224.  
  225.   PrintStatistics ();
  226.  
  227.   return;
  228. }
  229.  
  230. void
  231. RSysFlushAll (void)
  232. {
  233.   RSysFlushAllLibraries ();
  234.   RSysFlushAllDevices ();
  235.   RSysFlushAllFonts ();
  236.  
  237.   return;
  238. }
  239.